package org.smartit.client.config.menu;

import com.google.gwt.i18n.client.Dictionary;
import com.google.gwt.user.client.ui.Composite;

import java.util.Arrays;
import java.util.List;
import java.util.MissingResourceException;

/**
 * Date: 18/09/13
 * Time: 22:58
 */
public enum MenuItemEnum {

    Clients("clients", "clients_explanation", "menuclient", "850px", SubMenuItemEnum.CreateClient, SubMenuItemEnum.SearchClients, SubMenuItemEnum.ImportClients),
    Services("services", "services_explanation", "menuservice", "740px", SubMenuItemEnum.CreateService, SubMenuItemEnum.SearchServices),
    Sales("sales", "sales_explanation", "menusale", "620px", SubMenuItemEnum.MakeSale, SubMenuItemEnum.SearchSales),
    Payments("payments", "payments_explanation", "menupayment", "700px", SubMenuItemEnum.MakePayment, SubMenuItemEnum.SearchPayments, SubMenuItemEnum.ImportPayments),
    Reports("reports", "reports_explanation", "menureport", "580px", SubMenuItemEnum.CreateReport, SubMenuItemEnum.SearchReports),
    Communications("communications", "communications_explanation", "menucom", "580px", SubMenuItemEnum.CreateCommunication, SubMenuItemEnum.SearchCommunications),
    Documents("documents", "documents_explanation", "menucom", "580px", SubMenuItemEnum.CreateDocument, SubMenuItemEnum.SearchDocuments);

    String labelKey;
    String explanationLabelKey;
    String style;
    String subMenuWidth;
    List<SubMenuItemEnum> subMenuItemList;

    private MenuItemEnum(String labelKey, String explanationLabelKey, String style, String subMenuWidth, SubMenuItemEnum... subMenuItemList) {
        this.labelKey = labelKey;
        this.explanationLabelKey = explanationLabelKey;
        this.subMenuWidth = subMenuWidth;
        this.style = style;
        this.subMenuItemList = Arrays.asList(subMenuItemList);
    }

    public String getLabel() {
        Dictionary messages = Dictionary.getDictionary("messages");
        try {
            return messages.get(labelKey);
        } catch (MissingResourceException e) {
            return labelKey;
        }
    }

    public String getExplanationLabel() {
        Dictionary messages = Dictionary.getDictionary("messages");
        try {
            return messages.get(explanationLabelKey);
        } catch (MissingResourceException e) {
            return explanationLabelKey;
        }
    }

    public String getStyle() {
        return style;
    }

    public List<SubMenuItemEnum> getSubMenuItemList() {
        return subMenuItemList;
    }

    public String getSubMenuWidth() {
        return subMenuWidth;
    }
}
